﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DeskController : CharacterBase {
    private bool isGrabed = false;
    public bool IsGrabed
    {
        get { return isGrabed; }
        set { isGrabed = value; }
    }
    /// <summary>
    /// 发牌
    /// </summary>
    /// <returns></returns>
    public override Card DealCard()
    {
        return base.DealCard();
    }
    /// <summary>
    /// 添加牌
    /// </summary>
    /// <param name="card">添加的牌</param>
    /// <param name="isSeleced">是否被选中</param>
    public override void AddCard(Card card, bool isSeleced)
    {
        base.AddCard(card, isSeleced);
        if (isGrabed)
            return;
        
        CardUI[] Cards = CreatePoint.GetComponentsInChildren<CardUI>();
        for (int i = 0; i < Cards.Length; i++)
        {
            Cards[i].image.sprite = Resources.Load<Sprite>("Pokers/CardBack");
        }
    }
    /// <summary>
    /// 排序
    /// </summary>
    /// <param name="asc">升序</param>
    public override void Sort(bool asc)
    {
        base.Sort(asc);
    }
    /// <summary>
    /// 清空桌面
    /// </summary>
    public void ClearDesk()
    {
        CardList.Clear();
        CardUI[] Cards = CreatePoint.GetComponentsInChildren<CardUI>();
        for (int i = 0; i < Cards.Length; i++)
        {
            Cards[i] .Destroy();
        }
    }
}
